测试链接：https://leetcode.cn/problems/find-all-anagrams-in-a-string/?envType=study-plan-v2&envId=top-100-liked
class Solution {
public:
    vector<int> findAnagrams(string s, string p) {
        int n = s.size();
        int m = p.size();

        if(n < m) return {};

        vector<int> target(256, 0);
        vector<int> windows(256, 0);

        for(int i = 0; i < m; i++)
        {
            target[p[i] - 'a']++;
        }
        for(int i = 0; i < m; i++)
        {
            windows[s[i] - 'a']++;
        }

        vector<int> ans;
        if(target == windows)
        {
            ans.emplace_back(0);
        }

        for(int i = m ; i < s.size(); i++)
        {
            windows[s[i - m] - 'a']--;
            windows[s[i] - 'a']++;

            if(windows ==target)
            {
                ans.emplace_back(i - m+1);
            }
        }

        return ans;
    }
};